﻿using Nancy.Json;
using System.Collections.Generic;

namespace Zocono.WCS.Admin.Common
{
    public class JsonUtils
    {
        public static T Deserialize<T>(string json)
        {
            JavaScriptSerializer Serializer = new JavaScriptSerializer();
            return Serializer.Deserialize<T>(json);
        }

        public static string Serialize(object ob)
        {
            JavaScriptSerializer Serializer = new JavaScriptSerializer();
            return Serializer.Serialize(ob);
        }
        public static T JsonToModel<T>(string input)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            return js.Deserialize<T>(input);
        }
        public static string JsonToString<T>(T m)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            return js.Serialize(m);
        }
        public static List<T> DeserializeList<T>(string json)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            List<T> objs = js.Deserialize<List<T>>(json);
            return objs;
        }

    }
}
